import example.api.ShowDateByChina;
import example.api.ShowDateByEnglish;
import framework.annotation.XScan;
import framework.common.XConfig;
import framework.config.XServiceConfig;
import framework.handler.XRequestHandler;
import framework.provier.ServiceProvider;
import framework.registry.Registry;
import framework.registry.ZookeeperRegistry;
import framework.transport.server.NettyServer;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

public class Server {


    public static void spring() {

    }

    public static void noSpring() throws Exception {
//        Registry registry = new ZookeeperRegistry("127.0.0.1:2181");
//        XConfig xConfig = new XConfig();
//        ServiceProvider serviceProvider = new ServiceProvider(registry, xConfig);
//        // 发布服务
//        publishService(serviceProvider);
//        XRequestHandler xRequestHandler = new XRequestHandler(serviceProvider);
//        NettyServer nettyServer = new NettyServer(xRequestHandler);
//        nettyServer.start();
    }

    public static void main(String[] args) throws Exception {

        noSpring();
    }

    public static void publishService(ServiceProvider serviceProvider) {

        // 发布服务
        XServiceConfig xServiceConfig1 = new XServiceConfig();
        xServiceConfig1.setGroup("group1");
        xServiceConfig1.setVersion("3.1-cn");
        xServiceConfig1.setService(new ShowDateByChina());

        XServiceConfig xServiceConfig2 = new XServiceConfig();
        xServiceConfig2.setGroup("group1");
        xServiceConfig2.setVersion("3.-en");
        xServiceConfig2.setService(new ShowDateByEnglish());
        serviceProvider.publishService(Arrays.asList(xServiceConfig1, xServiceConfig2));
    }
}
